<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html class="no-js fixed-layout">
<head>
    <title>
        武汉热干面|长乐美食|武汉人最爱的早餐，没有之一
    </title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="/Public/vendor/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="/Public/vendor/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="/Public/vendor/assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="/Public/vendor/assets/css/admin.css">
    <link rel="stylesheet" href="/Public/assets/admin/css/common.css">

    
</head>
<body>

<header class="am-topbar am-topbar-inverse admin-header">
    <div class="am-topbar-brand">
        <strong>长乐美食城</strong>
        <small>后台管理中心</small>
    </div>

    <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only"
            data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span
            class="am-icon-bars"></span></button>

    <div class="am-collapse am-topbar-collapse" id="topbar-collapse">

        <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list">
            <li><a href="javascript:;"><span class="am-icon-envelope-o"></span> 收件箱 <span
                    class="am-badge am-badge-warning">5</span></a></li>
            <li class="am-dropdown" data-am-dropdown>
                <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;">
                    <span class="am-icon-users"></span> <?php echo ($_SESSION['user']['username']); ?>管理员 <span class="am-icon-caret-down"></span>
                </a>
                <ul class="am-dropdown-content">
                    <li><a href="#"><span class="am-icon-user"></span> 资料</a></li>
                    <li><a href="#"><span class="am-icon-cog"></span> 设置</a></li>
                    <li><a href="<?php echo U('User/logout');?>"><span class="am-icon-power-off"></span> 退出</a></li>
                </ul>
            </li>
            <li class="am-hide-sm-only"><a href="javascript:;" id="admin-fullscreen"><span
                    class="am-icon-arrows-alt"></span> <span class="admin-fullText">开启全屏</span></a></li>
        </ul>
    </div>
</header>


<div class="am-cf admin-main">
    <!-- sidebar start -->
    <div class="admin-sidebar am-offcanvas" id="admin-offcanvas">
    <div class="am-offcanvas-bar admin-offcanvas-bar">
        <ul class="am-list admin-sidebar-list">
            <li><a href="/admin"><span class="am-icon-home"></span> 首页</a></li>
            <li class="admin-parent">
                <a class="am-cf" data-am-collapse="{target: '#collapse-nav'}"><span class="am-icon-shopping-cart"></span>
                    商城中心 <span class="am-icon-angle-right am-fr am-margin-right"></span></a>
                <ul class="am-list am-collapse admin-sidebar-sub am-in" id="collapse-nav">
                    <li><a href="<?php echo U('Product/index');?>" class="am-cf"><span class="am-icon-product-hunt"></span> 商品管理<span
                            class="am-badge am-badge-success am-margin-right am-fr"><?php echo ($count['products']); ?></span></a></li>
                    <li><a href="<?php echo U('Category/index');?>"><span class="am-icon-calendar"></span> 分类管理</a></li>
                    <li><a href="<?php echo U('Advert/index');?>"><span class="am-icon-th"></span> 广告管理<span
                            class="am-badge am-badge-secondary am-margin-right am-fr"><?php echo ($count['adverts']); ?></span></a></li>
                    <!--<li><a href="admin-log.html"><span class="am-icon-calendar"></span> 系统日志</a></li>-->
                    <li><a href="<?php echo U('Product/trash');?>"><span class="am-icon-bug"></span> 商品回收站<span
                            class="am-badge am-badge-warning am-margin-right am-fr"><?php echo ($count['trashs']); ?></span></a></li>
                </ul>
            </li>
            <li><a href="admin-table.html"><span class="am-icon-table"></span> 表格</a></li>
            <li><a href="admin-form.html"><span class="am-icon-pencil-square-o"></span> 表单</a></li>
            <li><a href="#"><span class="am-icon-sign-out"></span> 注销</a></li>
        </ul>

        <div class="am-panel am-panel-default admin-sidebar-panel">
            <div class="am-panel-bd">
                <p><span class="am-icon-bookmark"></span> 公告</p>
                <p>时光静好，与君语；细水流年，与君同。—— Amaze UI</p>
            </div>
        </div>

        <div class="am-panel am-panel-default admin-sidebar-panel">
            <div class="am-panel-bd">
                <p><span class="am-icon-tag"></span> wiki</p>
                <p>Welcome to the Amaze UI wiki!</p>
            </div>
        </div>
    </div>
</div>

    <!-- sidebar end -->

    <!-- content start -->
    
    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf">
                    <strong class="am-text-primary am-text-lg">编辑广告</strong> /
                    <small>Ediit Ad</small>
                </div>
            </div>

            <hr>

            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-12">
                    <form class="am-form" action="/Admin/Advert/edit/id/15.html" method="post">
                        <div class="am-tabs am-margin" data-am-tabs>
                            <div class="am-tabs-bd">
                                <div class="am-tab-panel am-fade am-in am-active">
                                    <div class="am-g am-margin-top">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                            广告标题
                                        </div>
                                        <div class="am-u-sm-8 am-u-md-4">
                                            <input type="text" class="am-input-sm" value="<?php echo ($advert["title"]); ?>" required name="title">
                                        </div>
                                        <div class="am-hide-sm-only am-u-md-6">*必填，不可重复</div>
                                    </div>

                                    <div class="am-g am-margin-top">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                            广告图
                                        </div>

                                        <div class="am-u-sm-8 am-u-md-8 am-u-end col-end">
                                            <div class="am-form-group am-form-file">
                                                <button type="button" class="am-btn am-btn-success am-btn-sm new_thumb">
                                                    <i class="am-icon-cloud-upload" id="loading"></i> 上传广告图
                                                </button>
                                                <div id="upload_one" style="display: none;"></div>
                                                <div id="view_one">
                                                    <input type="hidden" name="thumb">
                                                    <img src="<?php echo ($advert["thumb"]); ?>" class="img-responsive"
                                                         style="margin-top:5px;max-height:150px;max-width: 150px;">
                                                </div>
                                            </div>

                                            <hr data-am-widget="divider" style="" class="am-divider am-divider-dashed"/>

                                            <div>
                                                <img src="" id="img_show" style="max-height: 200px;">
                                            </div>
                                        </div>
                                    </div>

                                    <div class="am-g am-margin-top">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                            广告描述
                                        </div>
                                        <div class="am-u-sm-8 am-u-md-4">
                                            <textarea rows="10" name="description"  placeholder="请输入广告描述"><?php echo ($advert["description"]); ?></textarea>
                                        </div>
                                        <div class="am-hide-sm-only am-u-md-6"></div>
                                    </div>

                                    <div class="am-g am-margin-top">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                            广告地址
                                        </div>
                                        <div class="am-u-sm-8 am-u-md-4">
                                            <input type="text" class="am-input-sm" value="<?php echo ($advert["url"]); ?>" required name="url">
                                        </div>
                                        <div class="am-hide-sm-only am-u-md-6"></div>
                                    </div>
                                    <div class="am-g am-margin-top">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                            排序
                                        </div>
                                        <div class="am-u-sm-8 am-u-md-4">
                                            <input type="text" class="am-input-sm" value="<?php echo ($advert["sort_order"]); ?>"  required name="sort_order">
                                        </div>
                                        <div class="am-hide-sm-only am-u-md-6"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="am-margin">
                            <button type="submit" class="am-btn am-btn-primary am-radius">提交保存</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <footer class="admin-content-footer">
            <hr>
            <p class="am-padding-left">© 2014 AllMobilize, Inc. Licensed under MIT license.</p>
        </footer>
    </div>

    <!-- content end -->

</div>

<a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu"
   data-am-offcanvas="{target: '#admin-offcanvas'}"></a>



<!--[if (gte IE 9)|!(IE)]><!-->
<script src="/Public/vendor/assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="/Public/vendor/assets/js/amazeui.min.js"></script>
<script src="/Public/vendor/assets/js/app.js"></script>


    <script src="/Public/vendor/bootstrapextend/js/bootstrap.extend.js"></script>
    <script src="/Public/vendor/validate/jquery.validate.js"></script>
    <script src="/Public/vendor/validate/localization/messages_zh.js"></script>
    <script>
        $(function () {
            //给上传图片按钮绑定事件
            $('.new_thumb').click(function () {
                $("#file_upload_1-button").click();
            });

            $(".am-form").validate({
                onfocusout: function (element) {
                    $(element).valid();
                }
            });

            //上传单张
            $('#upload_one').Huploadify({
                uploader: '<?php echo U("Admin/Uploadfile/upload");?>',
                fileTypeExts: '*.gif;*.jpg;*.jpeg;*.png;*.bmp',
                //fileSizeLimit:{:C('UPLOAD_IMAGE_SIZE')}*1024,
                buttonText: '上 传 图 片',
                onUploadComplete: function (file, data) {
                    data = $.parseJSON(data);
                    $('#view_one img').attr('src', data.real_path);
                    $('#view_one input').attr('value', data.real_path);

                }
            });


            //上传多张
            $('#upload_more').Huploadify({
                uploader: '<?php echo U("Admin/Uploadfile/upload");?>',
                fileTypeExts: '*.gif;*.jpg;*.jpeg;*.png;*.bmp',
//                fileSizeLimit:{:C('UPLOAD_IMAGE_SIZE')}*1024,
                buttonText: '上传多张图片',
                onUploadComplete: function (file, data) {
                    var data = $.parseJSON(data);
                    //console.log(data);
                    if (data.error == 1) {
                        alertMessager(data.message);
                    } else {
                        var input = $('#view_more input');
                        var new_img = '<span class="img-box">' +
                            '<img class="img img-responsive" width="80" src="' + data.real_path + '">' +
                            '<a class="label label-danger remove-picture" href="javascript:void(0);" >删除</a>' +
                            '<input type="hidden" name="gallery[]" value="' + data.real_path + '">' +
                            '</span>';
                        $('#view_more').append(new_img);
                    }
                }
            });

            //删除图片 <i class="glyphicon glyphicon-remove-sign remove-picture"></i>
            $('#view_more').on('click', '.remove-picture', function () {
                var ready_for_remove_id = $(this).closest('.img-box').find('img').attr('data-id'); //获取待删除的图片ID
                if (!ready_for_remove_id) {
                    alertMessager('错误');
                }
                var current_picture_ids = $('#view_more input').val().split(","); //获取当前图集以逗号分隔的ID并转换成数组
                current_picture_ids.remove(ready_for_remove_id); //从数组中删除待删除的图片ID
                $('#view_more input').val(current_picture_ids.join(',')) //删除后覆盖原input的值
                $(this).closest('.img-box').remove(); //删除图片预览图
            });
        })
    </script>

</body>
</html>